package com.seveneight.baijiesteward.views;

import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;

import com.flyco.dialog.listener.OnOperItemClickL;
import com.flyco.dialog.widget.ActionSheetDialog;
import com.seveneight.baijiesteward.bean.BankBean;
import com.seveneight.baijiesteward.ui.user.fragment.IdentifyFragment;

import java.util.List;

/**
 * Created by user1 on 2018/3/20.
 */

public class BankListDialog {

    private List<BankBean> data;
    private TextView textView;
    private String bankId = "";

    private Context context;
    private ActionSheetDialog dialog;

    public BankListDialog(Context context, List<BankBean> data, TextView textView,String bankId) {
        this.data = data;
        this.bankId=bankId;
        this.textView = textView;
        this.context = context;
        getBankList();
    }


    public void getBankList() {
        final String[] stringItems = new String[data.size()];
        for (int i = 0; i < data.size(); i++) {
            stringItems[i] = data.get(i).getBankAbbrName();
        }
        dialog = new ActionSheetDialog(context, stringItems, null);
        dialog.title("手动选择银行")//
                .titleTextSize_SP(14.5f);
        dialog.setOnOperItemClickL(new OnOperItemClickL() {
            @Override
            public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) {
                bankId = data.get(position).getId();
                textView.setText(data.get(position).getBankAbbrName());
                dialog.dismiss();
            }
        });
    }

    public String getBankId() {
        return bankId;
    }

    public void show() {
        dialog.show();
    }
}
